package com.menqui.localizame.Gps;

import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Date;

import android.content.Context;
import android.location.Location;
import android.util.Log;

public class GpsFichero {
	private String LOG_TAG = getClass().toString();
	private String name = "";
	private Context context = null;

	public GpsFichero(Context context) {
		name = String.valueOf((new Date()).getTime()) + ".mqg";
		this.context = context;
	}

	public void setLocalizacion(Location location) {
		String cadena = location.getTime() + ";" +
						location.getLatitude() + ";" +
						location.getLongitude() + ";" +
						location.getAltitude() + "|";
		try {
			FileOutputStream fos = context.openFileOutput(name, Context.MODE_APPEND);
			fos.write(cadena.getBytes());
			fos.close();
		} catch (IOException e) {
			Log.w(LOG_TAG, "Error writing " + name, e);
		}
	}
}
